package com.yanqu.road.logic.activity.foxcard.game.effect;

import com.yanqu.road.entity.activity.foxcard.FoxBaseCard;
import com.yanqu.road.entity.activity.foxcard.FoxHandCard;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardGameLogic;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardShowType;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardTriggerType;

import java.util.Collections;
import java.util.List;

/**
 * 每刷新x次，加效果
 */
public class FoxCardEffect41 extends FoxCardEffectBase {
    @Override
    protected void effectHandle(FoxCardGameLogic gameLogic, FoxHandCard handCard) {
        if (triggerType == eFoxCardTriggerType.ADD && handCard == null) {
            if (effectCard.getEffectValues().isEmpty()) {
                effectCard.getEffectValues().add(0l);
                effectCard.getEffectValues().add(0l);
            }
        }
        if (triggerType == eFoxCardTriggerType.REFRESH_SHOP) {
            int perNum = Integer.valueOf(effectConfig.getParamsList().get(0));
            if (effectCard.getEffectValues().isEmpty()) {
                effectCard.getEffectValues().add(0l);
                effectCard.getEffectValues().add(0l);
            }

            int refreshAmount = effectCard.getEffectValues().get(1).intValue();
            refreshAmount++;
            effectCard.getEffectValues().set(1, (long) refreshAmount);
            int level = refreshAmount / perNum;
            effectCard.getEffectValues().set(0, (long) level);
            gameLogic.newFoxShow(eFoxCardShowType.EFFECT_CARD_LV_UP.getValue()).setSettleCards(Collections.singletonList(effectCard)).setShowValue(1);
        } else if (triggerType == eFoxCardTriggerType.AFTER_SCORE) {
            if (effectCard.getEffectValues().isEmpty()) {
                effectCard.setEffectValues(Collections.singletonList(0L));
            }
            int level = effectCard.getEffectValues().get(0).intValue();

            int addBaseScore = level * Integer.valueOf(effectConfig.getUpgradeParamsList().get(0));
            int addBaseScoreMulti = level * Integer.valueOf(effectConfig.getUpgradeParamsList().get(1));
            int addBaseMulti = level * Integer.valueOf(effectConfig.getUpgradeParamsList().get(2));
            int addBaseMultiMulti = level * Integer.valueOf(effectConfig.getUpgradeParamsList().get(3));
            int goldChange = level * Integer.valueOf(effectConfig.getUpgradeParamsList().get(4));

            List<FoxBaseCard> foxEffectCards = Collections.singletonList(effectCard);

            gameLogic.addBaseScore(addBaseScore, foxEffectCards, null); //加基础筹码
            gameLogic.addBaseScoreMulti(addBaseScoreMulti, foxEffectCards, null); //当前基础筹码乘算
            gameLogic.addBaseMulti(addBaseMulti, foxEffectCards, null); //加基础倍率
            gameLogic.addBaseMultiMulti(addBaseMultiMulti, foxEffectCards, null); //当前基础倍率乘算
            gameLogic.goldChange(goldChange, foxEffectCards, null, triggerType); //加金币
        }

    }
}
